import { PipeTransform, Injectable } from '@nestjs/common';
import { CreateUserDto } from '../dto/user.dto';
import { PasswordEncryptionService } from 'src/services/password.service';

@Injectable()
export class PasswordPipe implements PipeTransform {
  async transform(value: CreateUserDto) {
    const { password, ...data } = value;
    const newPassword = await PasswordEncryptionService.encryptPassword(
      password,
    );
    return { ...data, password: newPassword };
  }
}
